package com.learn.my.aop;


import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * 配置aop
 */
@Component
@Aspect
public class AopLog {


    @Before("execution(* com.learn.my.service.impl.*.*(..))")
    public void begin(){
        System.out.println("前置通知");
    }


    @After("execution(* com.learn.my.service.impl.*.*(..))")
    public void commit(){
        System.out.println("后置通知");
    }


    @AfterReturning("execution(* com.learn.my.service.impl.*.*(..))")
    public void runningReturn(){
        System.out.println("返回通知通知");
    }


    @AfterThrowing("execution(* com.learn.my.service.impl.*.*(..))")
    public void afterThrowing(){
        System.out.println("异常通知");
    }



    @Around("execution(* com.learn.my.service.impl.*.*(..))")
    public Object  around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{
        System.out.println("环绕通知开始");
        return proceedingJoinPoint.proceed();
    }


    @Around("execution(* com.learn.my.cotroller.*.*(..))")
    public Object aroundController(ProceedingJoinPoint joinPoint) throws Throwable{
        System.out.println("controller:环绕通知开始");
        return joinPoint.proceed();
    }
}
